Thuộc tính chi tiết trong ListView không hiển thị (Details property in ListView not displaying)


問題描述

Thuộc tính chi tiết trong ListView không hiển thị (Details property in ListView not displaying)

I set my list view to details to try and create columns, but the columns will not display. What is blocking the columns from displaying?

Imports System.IO
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Menu


Public Class Jonathan_Roda_P4
    Dim TitlesData(21)
    Dim BOData(21)

    'Clear Button Function
    Private Sub ResetClearToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ResetClearToolStripMenuItem.Click
        'Clear Title LV
        DispResView.Clear()
        'Clear Box Office List
        BOList.Items.Clear()
        'Resets User Message to default
        UsrMsg.Text = "Data Not Loaded"
    End Sub

    'Help/Instructions Properties

    Private Sub InstructionsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InstructionsToolStripMenuItem.Click
        MessageBox.Show("1. Click the 'Load Files' Button" & vbNewLine _
                        & vbNewLine _
                        & "2. Select two respective files." & vbNewLine _
                        & "      (Note: Each file must have the same number of lines)" & vbNewLine _
                        & "      (Note: You may only select two files)" & vbNewLine _
                        & vbNewLine _
                        & "3. Select the 'Open' button to load your selected files" & vbNewLine _
                        & vbNewLine _
                        & "4. The Box Office Lister will now display each file's contents as it appears in the file" & vbNewLine _
                        & vbNewLine _
                        & "5. Clicking any of the sort buttons will reorder the displayed content as follows:" & vbNewLine _
                        & "       a) Sort by A‑Z: Sorts the displayed content alphabetically by title" & vbNewLine _
                        & "       b) Sort by Z‑A: Sorts the displayed content in reverse alphabetical order by title" & vbNewLine _
                        & "       c) Sort by 0‑9: Sorts the displayed content in ascending numerical order by Box Office Amount" & vbNewLine _
                        & "       d) Sort by 9‑0: Sorts the displayed content in descending numerical order by Box Office Amount" & vbNewLine _
                        & vbNewLine _
                        & "6. Clicking the 'Clear' button will reset the program and require you to select two new files" & vbNewLine _
                        & vbNewLine _
                        & "7. Clicking the 'Exit' button will close the program" & vbNewLine _
                        & vbNewLine _
                        & "8. TOP THIRD" & vbNewLine _
                        & "      Top Third lists the top 1/3 missions in order of Box Office Amount", "007 Box Office Lister Instructions")
    End Sub

    'File/Exit Properties
    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    'Exit Button Properties
    Private Sub ExitBtn_Click(sender As Object, e As EventArgs) Handles ExitBtn.Click
        Application.Exit()
    End Sub

    Private Sub ClearBtn_Click(sender As Object, e As EventArgs) Handles ClearBtn.Click
        DispResView.Clear()
        UsrMsg.Text = "Data Not Loaded"
    End Sub

    Private Sub LoadButton_Click(sender As Object, e As EventArgs) Handles LoadButton.Click

        With OpenFileDialog1
            .CheckPathExists = True
            .DefaultExt = "txt"
            .Filter = _
             "Text files (*.txt)|*.txt"
            .Multiselect = True
            .RestoreDirectory = True
            .Title = "Open"
            .ValidateNames = True
            DispResView.Clear()
        End With
        'Resets User Message to default if another message is displayed
        UsrMsg.Text = "Data Not Loaded"

        'Sets Default folder to Desktop
        OpenFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

        'OpenFileDialog Properties
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim count As Integer = 0
            For Each s As String In OpenFileDialog1.FileNames
                Dim sAllData() As String = System.IO.File.ReadAllLines(s)
                count = count + 1
            Next
            For Each openFile As String In OpenFileDialog1.FileNames
                Dim getAllData() As String = File.ReadAllLines(openFile)
                For i As Integer = 0 To getAllData.Length ‑ 1
                    DispResView.Items.Add(getAllData(i))
                Next
            Next
        End If

    End Sub

    Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

    End Sub
End Class

參考解法

方法 1:

Have you added all your column headers to ListView.Columns?  The ListView will not display more columns than it has headers for.

DispResView.Columns.Add "Name"
DispResView.Columns.Add "Size"
'etc.

Note that if you want the column headers not to be erased, you should be calling DispResview.Items.Clear instead of DispResView.Clear.

(by NewProgrammerj__m)

參考文件

  1. Details property in ListView not displaying (CC BY‑SA 3.0/4.0)

#listview #vb.net






相關問題

ListView中的序列號列 (Serial number Column in ListView)

狀態列表可繪製在預蜂窩版本上無法正常工作 (State list drawable not working properly on pre-honeycomb versions)

我可以減少列表視圖的執行時間嗎? (Can i reduce execution time of listview?)

ListView Windows 8 多個索引 (ListView Windows 8 multiple indexes)

如何通過單擊歌曲列表來播放歌曲 (How to play the song by clicking the lists of song)

Thuộc tính chi tiết trong ListView không hiển thị (Details property in ListView not displaying)

如何從 DataModel 動態訪問數據以獲取 Blackberry 10 中的可折疊列表 (How to access data dynamically from DataModel for collapsible list in Blackberry 10)

android如何將listview項目發送到另一個活動 (android How to send listview item to another activity)

實現 RecyclerView (Implementing RecyclerView)

如何刪除列表視圖底部的多餘空間? (How can I remove extraspace in listview bottom?)

ListViewItem ItemSelectionChangedEvent 觸發 4 次 [e.Selected 觸發兩次] 導致 Win32 異常未處理 (ListViewItem ItemSelectionChangedEvent Fires 4 times [e.Selected fires twice] leads to Win32 Exception Unhandled)

Kivy:如何使用 RecycleView 在 Kivy 中顯示具有可變行的列表? (Kivy: how to display a list with variable rows in Kivy with a RecycleView?)







留言討論